const express = require("express");
const app = express();
const login = require("./router/login.js");
// 引入login模块的路由
const bodyParser = require("body-parser");
app.all("*", function(req, res, next) {
    res.header("Access-Control-Allow-Credentials", "true");
    res.header("Access-Control-Allow-Origin", "*");
    res.header(
        "Access-Control-Allow-Headers",
        "Content-Type, authorization, Cache-Control"
    );
    res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
    res.header("Access-Control-Allow-Credentials", "true");
    next();
});
//定义跨域

app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
// 对参数进行处理
app.use("/", login);
//注册login模块的路由
app.listen("3001", (req, res) => {
    console.log("running");
});
//启动一个服务端口为3001